//
//  CalculatorButton.swift
//  Fruta
//
//  Created by yanhangpu on 2021/6/25.
//  Copyright © 2021 Apple. All rights reserved.
//

import SwiftUI

struct CalculatorButton: View {
    let title:String
    let size:CGSize
    let fontSize:CGFloat
    let foregroundColor:Color
    let backgroundColorName:String
    let cornerRadius:CGFloat
    let action:() -> Void

    var body: some View {
        /// Plan A
        Button(action: {
            action()
        }) {
            Text(self.title)
                .foregroundColor(foregroundColor)
                .font(.system(size: fontSize))
                .frame(width: size.width, height: size.height)
                .background(Image(backgroundColorName))
                .cornerRadius(cornerRadius)
        }
    }
}

struct CalculatorButton_Previews: PreviewProvider {
    static var previews: some View {
        CalculatorButton(title: "0", size: CGSize(width: 88, height: 88), fontSize: 76, foregroundColor: .white, backgroundColorName: "calculatorBackground", cornerRadius: 88*0.5, action: {
            
        })
    }
}
